<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2025/8/29
  Time: 14:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>$Title$</title>
    <script type="text/javascript" src="js/jquery-1.8.3.js"></script>
    <script>
      $(document).ready(function () {

      })
      $(document).on("click","input[name]",function () {

        var fuc =  $(this).attr("name")
        //获取user对象,发送异步请求
        var uname=$("#uname").val()
        var upassword = $("#upassword").val()
        if(uname.length<=4||upassword.length<=4){
          alert("登录失败，用户名或密码错误")
        }
        else{
            alert(fuc+"******")
          if(fuc=="login"){
            $.get("User/login",{"uname":uname,"upassword":upassword},function (boo) {

            if(boo){
                alert("登录成功")
              window.location.href="booklend.jsp?uname="+uname
            }
            else{
              alert("登录失败，用户名或密码错误")
            }
          })
          }
          /*if(fuc=="注册"){
            $.get("User/login",user,function (boo){

            })
          }*/

        }
      })
    </script>
  </head>
  <body>
      <form>
          <table>
              <caption>图书借阅系统</caption>
              <tbody>

              <tr>
                <td><b>登录账户</b></td>
                <td>
                  <input id="uname"  type="text">
                </td>
              </tr>

              <tr>
                <td><b>登录密码:</b></td>
                <td>
                  <input id="upassword" type="text">
                </td>
              </tr>
              <tr>
                  <td colspan="2">
                      <input type="button" name="login" value="登录">

                  </td>
                  <td>
                      <input type="button" name="register" value="注册">
                  </td>
              </tr>

              </tbody>

          </table>
      </form>
  </body>
</html>
